GBML manual / Drawing

xscale

Horizontal scale. 1 is normal size. Negative mirrors it, the same visual result flip_x gives.

Works differently on Game Boy - A turned, resized or leaned sprite shows the nearest look the build draws ahead of time: turns in steps (Project Settings: Sprite turn steps), a few sizes and leans, and a negative size mirrors exactly. The looks share the 384 tiles of video memory, so there is room for few.

Works differently on Game Boy Color - On the Game Boy Color a turned, resized or leaned sprite shows the nearest of the looks the build drew ahead of time: turns in steps (Project Settings: Sprite turn steps), a few sizes and leans. A negative size mirrors it exactly.

Works differently on Sega Genesis - The Sega Genesis can turn a picture over (a size of 1 or -1), but it cannot stretch or shrink one. Make the sizes you need as frames of an animation instead.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

xscale: real

Description

Horizontal scale - 1 is the sprite's normal size, 2 is doubled width, 0.5 is halved. Negative values mirror it, the same visual result flip_x gives, though flip_x is the clearer way to say "mirrored, same size" when scale itself is not otherwise in play.

Example

xscale = 1.3;

Stretches this instance to 130% of its normal width - a flat, one-shot horizontal stretch (a squash-and-stretch wobble is the same idea animated over several frames, easing xscale up and back down around 1).

A real capture - the arrow stretched to 130% of its normal widthA real capture - the arrow stretched to 130% of its normal width
A real capture - the arrow stretched to 130% of its normal width

On the GBA

Like angle, any xscale/yscale other than the default 1 claims one of the hardware's 32 affine matrices for as long as it stays that way - see Budgets. A pure mirror is the one exception: xscale = -1 with yscale left at 1 and angle at 0 costs nothing beyond what flip_x alone already costs - no affine matrix, exactly as if xscale had stayed at 1. Any OTHER magnitude (-2, 0.5, and so on) claims one, same as a non-zero angle.

A turned or enlarged picture is drawn into a box at most twice the size of its sprite, and the hardware cuts off anything that would stick out past it. A 16 pixel sprite can be made 2 times as big and still show all of itself; at 3 times, only its middle 32 pixels are drawn. Turn a sprite 45 degrees and the most it can be enlarged is about 1.4 times. For something bigger than that, draw it from a bigger sprite. Gbabel turns the bigger box on for you whenever it is needed (see Budgets) - you only meet the limit above, never a missing row of pixels at a tiny turn or a tiny enlargement.

See also: angleflip_x